﻿using System;
using System.Windows.Data;
using System.Globalization;
using System.Collections.Generic;

namespace EasySL.Controls
{
    public class ExConverter : IValueConverter
    {
        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var data = value as Dictionary<string, object>;

            string bindProperty = parameter.ToString();

            if (data != null && data.ContainsKey(bindProperty) && data[bindProperty] != null)
                return Convert(data[bindProperty]);
            else if (!bindProperty.EndsWith("_Order"))
                return "N/A";
            else
                return null;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return string.Empty;
        }
        #endregion

        public virtual object Convert(object value)
        {
            return value.ToString();
        }
    }
}


